extends Control

var peer = ENetMultiplayerPeer.new()
var port = 8088
var ip = "127.0.0.1"

# Called when the node enters the scene tree for the first time.
func _ready():
	if peer.create_client(ip,port):
		GlobalPopup.print_text("启动客户端失败，请检查端口！")
	else:
		multiplayer.multiplayer_peer = peer
		GlobalPopup.print_text("启动客户端成功")
	#print(multiplayer.get_unique_id())
	#multiplayer.rpc(0,GlobaWeb,"login_account",["舒荣森",multiplayer.get_unique_id()])
	#GlobaWeb.login_account.rpc_id(1,"舒荣森",multiplayer.get_unique_id())
		
	pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	pass


func _on_button_pressed():
	Global.user_name = %LineEdit.text
	GlobaWeb.login_account.rpc_id(1,Global.user_name,multiplayer.get_unique_id())
	await get_tree().create_timer(0.1).timeout
	GlobaWeb.join_Map.rpc_id(1,"测试地图",Global.user_name)
	Loading.load_path("res://client/game/test.tscn")
	queue_free()
	#GlobaWeb.test.rpc()
	pass # Replace with function body.


#func _on_line_edit_text_changed(new_text):
	#Global.user_name = new_text
	#pass # Replace with function body.
